//
//  ViewController.m
//  bleDemo
//
//  Created by zt on 2020/4/13.
//  Copyright © 2020 XB. All rights reserved.
//

#import "ViewController.h"
#import "BleManager.h"
#import "FSBleDelegate.h"

@interface ViewController () <FSCentralScanDelegate>

@property (nonatomic, strong) BleManager *manager;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"开始");
    self.manager = [BleManager managerWithDelegate:self];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if ([self.manager startScan]) { // 可以扫描就来扫描外设
        [self.manager startScan];
    }
}

#pragma mark 蓝牙管理器的代理方法
- (void)manager:(BleManager *)manager didUpdateState:(BleManagerState)state {
    // 蓝牙状态回调
}

- (void)manager:(BleManager *)manager willScanWithServices:(NSMutableArray<CBUUID *> *)services {
    // 扫描指定的服务
    [services addObject:UUID(@"FFF0")];
}

- (BOOL)manager:(BleManager *)manager willDiscoverDevice:(BleDevice *)device {
    return YES;
}

- (void)manager:(BleManager *)manager didDiscoverDevice:(BleDevice *)device {
    NSLog(@"%@", device.name);
    if ([device.name isEqualToString:@"FS-74907B"]) {
        [device connect];
    }
}
#pragma mark 蓝牙外设的代理方法












@end
